﻿#pragma once
#include <vector>

#include <pcl/pcl_base.h>
#include <Eigen/Core>

using namespace Eigen;
using namespace std;
namespace oil
{
class RasterSurface
{
public:
	RasterSurface(const Vector4f& min, const Vector4f& max, float width, float height);
	RasterSurface(const Vector4f& min, int rows, int cols, float width, float height);
	RasterSurface();
	~RasterSurface();

	inline int rows() const { return rows_; };
	inline int cols() const { return cols_; };
	inline const Vector4f& getmin() { return min_; };
	inline float space_x() const { return cell_width_; };
	inline float space_y() const { return cell_height_; };

	double operator()(int row, int col) const;
	double operator()(double x, double y);

	float& operator()(int row, int col);
	// x -> [0,1]
	double cubicInterpolate(double p[4], double x) const;
	double bicubicInterpolate(double p[4][4], double x, double y) const;

	void save(const string& file_path);

public:
	int rows_;
	int cols_;
	Vector4f min_;
	float cell_width_;
	float cell_height_;
	vector<float> data_;

public:
	EIGEN_MAKE_ALIGNED_OPERATOR_NEW

};

}
